package com.sky.mapper.admin;

import com.github.pagehelper.Page;
import com.sky.dto.CategoryDTO;
import com.sky.dto.CategoryPageQueryDTO;
import com.sky.pojo.Category;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @Description FoodManagementMapper
 * @Author luohai
 * @Date 2024-09-30
 */
@Mapper
public interface CategoryManagementMapper {
    /**
     * 根据名称查询分类
     * @param name
     */
    @Select("select * from category where name = #{name}")
    Category searchCategoryByName(String name);
    /**
     * 新增分类
     * @param category
     * @return
     */
    @Insert("insert into category(type, name, sort, status, create_time, update_time, create_user, update_user) values (#{type},#{name},#{sort},#{status},#{createTime},#{updateTime},#{createUser},#{updateUser})")
    void addCategory(Category category);

    /**
     * 分类分页查询
     * @param categoryPageQueryDTO
     * @return
     */
    List<Category> classificationPaginationQuery(CategoryPageQueryDTO categoryPageQueryDTO);

    /**
     * 根据ID删除分类
     * @param id
     * @return
     */
    @Delete("delete from category where id =#{id}")
    void deleteCategoryById(Integer id);

    /**
     * 根据ID修改分类
     * @param category
     * @return
     */

    void changeClassificationById(Category category);

    /**
     * 启用禁用分类
     * @param status
     * @return
     */

    void enableAndDisableClassification(Integer status,Integer id);

    /**
     * 根据类型查询分类
     * @param type
     * @return
     */
    @Select("select * from category where type = #{type}")
    List<Category> list(Integer type);
}
